var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("GlobalParams"),
    a = e("AssetsManager"),
    i = e("ModuleUI"),
    r = e("Game"),
    s = e("season_item_node"),
    l = cc._decorator,
    c = l.ccclass,
    d = l.property,
    h = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.season_content_view = null),
                (t.season_item_node = null),
                (t.my_level_icon = null),
                (t.my_level_name = null),
                (t.level_star_node = null),
                (t.season_scroll_view = null),
                (t.award_node_info = []),
                (t.video_node_info = []),
                (t.level_icon = null),
                (t.level_num = ["I", "II", "III", "IV"]),
                (t.level_name = ["青铜", "白银", "黄金", "铂金", "钻石", "宗师", "王者"]),
                (t.min_count_num = 0),
                (t.max_count_num = 0),
                (t.show_season_index = 0),
                t
            );
        }
        return (
            __extends(t, e),


            (t.prototype.onDisable = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();

            }),

            (t.prototype.initView = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();
                Adv_skd.default.instance.showInterstitialAd();
                Adv_skd.default.instance.showGridAdLeftOne();
                Adv_skd.default.instance.showGridAdRightOne();

                e.prototype.initView.call(this);
                var t = n.GlobalParams.PlayerInfo.value;
                (this.my_level_icon.spriteFrame = a.default
                    .getInstance()
                    .getPlayerLevelExp(t.level > 28 ? 28 : t.level)),
                    (this.my_level_name.string =
                        this.level_name[t.level % 4 == 0 ? t.level / 4 - 1 : Math.floor(t.level / 4)] +
                        " " +
                        this.level_num[t.level % 4 == 0 ? 3 : (t.level % 4) - 1]);
                for (var o = 0; o < 4; o++) this.level_star_node.children[o].active = o <= t.exp;
                (this.min_count_num = t.level - 3),
                    (this.min_count_num = this.min_count_num < 1 ? 1 : this.min_count_num),
                    (this.max_count_num = t.level < 5 ? 8 : t.level + 4),
                    (this.max_count_num = this.max_count_num > 29 ? 29 : this.max_count_num),
                    this.addSeasonNode(this.min_count_num, this.max_count_num);
            }),
            (t.prototype.addEvent = function () {
                this.season_scroll_view.on("scroll-to-left", this.scollToLeft, this),
                    this.season_scroll_view.on("scroll-to-right", this.scollToRight, this);
            }),
            (t.prototype.scollToLeft = function () {
                if (this.min_count_num > 1) {
                    var e = this.min_count_num;
                    (this.min_count_num -= 5),
                        (this.min_count_num = this.min_count_num < 1 ? 1 : this.min_count_num),
                        this.addSeasonNode(this.min_count_num, e);
                }
            }),
            (t.prototype.scollToRight = function () {
                if (this.max_count_num < 29) {
                    var e = this.max_count_num;
                    (this.max_count_num += 5),
                        (this.max_count_num = this.max_count_num > 29 ? 29 : this.max_count_num),
                        this.addSeasonNode(e, this.max_count_num);
                }
            }),
            (t.prototype.addSeasonNode = function (e, t) {
                for (var o = e; o < t; o++) {
                    var n = cc.instantiate(this.season_item_node);
                    (n.active = !0), n.getComponent(s.default).showSeasonInfo(o), n.setParent(this.season_content_view);
                }
            }),
            (t.prototype.OnClick = function (t) {
                switch ((e.prototype.OnClick.call(this, t), t.node.name)) {
                    case "back_btn":
                        this.node.destroy();
                        break;
                    case "up_level":
                        (n.GlobalParams.ChangeGameMode = 0), this.uiManager.showPopup("MatchViewUI");
                }
            }),
            (t.prototype.onCollisionEnter = function (e) {
                var t,
                    o = e.node;
                if (((t = o.zIndex < 8 ? 4 : 4 * Math.floor(o.zIndex / 4)), this.show_season_index != t)) {
                    (this.show_season_index = t),
                        (this.level_icon.spriteFrame = a.default
                            .getInstance()
                            .getPlayerLevelExp(this.show_season_index));
                    for (var n = this.show_season_index, i = r.default.season_info[n - 1], s = 0; s < 5; s++)
                        (this.award_node_info[s].active = !1), (this.video_node_info[s].active = !1);
                    for (s = 0; s < 9; s++) {
                        var l = null,
                            c = null;
                        0 == s || 1 == s
                            ? ((l = this.award_node_info[s]), (c = this.video_node_info[s]))
                            : 7 == s
                            ? ((l = this.award_node_info[3]), (c = this.video_node_info[3]))
                            : 8 == s
                            ? ((l = this.award_node_info[4]), (c = this.video_node_info[4]))
                            : ((l = this.award_node_info[2]), (c = this.video_node_info[2]));
                        var d = -1 != i.award_type.indexOf(s) ? i.award_num[i.award_type.indexOf(s)] : 0;
                        l.active ||
                            ((l.active = d > 0),
                            (l.getChildByName("num").getComponent(cc.Label).string = "" + d),
                            l.active &&
                                -1 == [0, 1, 7, 8].indexOf(s) &&
                                (l.children[0].getComponent(cc.Sprite).spriteFrame = a.default
                                    .getInstance()
                                    .getDowerImagerFrame("dower_" + (s - 2) + "_0")));
                        var h = -1 != i.extra_type.indexOf(s) ? i.extra_num[i.extra_type.indexOf(s)] : 0;
                        c.active ||
                            ((c.active = h > 0),
                            (c.getChildByName("num").getComponent(cc.Label).string = "" + h),
                            c.active &&
                                -1 == [0, 1, 7, 8].indexOf(s) &&
                                (c.children[0].getComponent(cc.Sprite).spriteFrame = a.default
                                    .getInstance()
                                    .getDowerImagerFrame("dower_" + (s - 2) + "_0")));
                    }
                    (this.award_node_info[0].parent.active =
                        this.award_node_info[0].active || this.award_node_info[1].active),
                        (this.award_node_info[2].parent.active =
                            this.award_node_info[2].active ||
                            this.award_node_info[3].active ||
                            this.award_node_info[4].active),
                        (this.video_node_info[0].parent.active =
                            this.video_node_info[0].active || this.video_node_info[1].active),
                        (this.video_node_info[2].parent.active =
                            this.video_node_info[2].active ||
                            this.video_node_info[3].active ||
                            this.video_node_info[4].active);
                }
            }),
            __decorate([d(cc.Node)], t.prototype, "season_content_view", void 0),
            __decorate([d(cc.Node)], t.prototype, "season_item_node", void 0),
            __decorate([d(cc.Sprite)], t.prototype, "my_level_icon", void 0),
            __decorate([d(cc.Label)], t.prototype, "my_level_name", void 0),
            __decorate([d(cc.Node)], t.prototype, "level_star_node", void 0),
            __decorate([d(cc.Node)], t.prototype, "season_scroll_view", void 0),
            __decorate([d(cc.Node)], t.prototype, "award_node_info", void 0),
            __decorate([d(cc.Node)], t.prototype, "video_node_info", void 0),
            __decorate([d(cc.Sprite)], t.prototype, "level_icon", void 0),
            __decorate([c], t)
        );
    })(i.default);
o.default = h;
